#include <math.h>

double plinear(double x)
{
    return 1 - x;
}

double pquadratic(double x)
{
    return 1 - x + x*x;
}

double pcubic(double x)
{
    return 1 - x + x*x - x*x*x;
}

double fsin(double x)
{
    return abs(cos((5-x)*0.314));
}

double plinear(double x, double y)
{
    return 1 - x - y + x*y;
}

double pquadratic(double x, double y)
{
    return 1 - x + x*x 
        - y + x*y - x*x*y 
        + y*y - x*y*y + x*x*y*y;
}

double pcubic(double x, double y)
{
    return 1 - x + x*x - x*x*x
        + (-1 + x - x*x + x*x*x)*y
        + (1 - x + x*x - x*x*x)*y*y
        + (-1 + x - x*x + x*x*x)*y*y*y;
}

double fsin(double x, double y)
{
    return abs(cos((5-x)*0.314) * sin(y*0.314));
}

double plinear(double x, double y, double z)
{
    return 1 - x - y - z + x*y + x*z + y*z - x*y*z;
}

double fsin(double x, double y, double z)
{
    return abs(cos((5-x)*0.314) * sin(y*0.314) * sin(z*0.314));
}
